class TreeNode:
    def __init__(self, value = None, parent = None, children = list()):
        self.children = children
        self.value = value
        self.parent = parent

    def getvalue(self):
        """
        :return: value of node
        """
        return self.value

    def setvalue(self, newvalue):
        """
        :param newvalue: the new value of node
        :return: the new value of node
        """
        self.value = newvalue
        return self.value

    def getparent(self):
        """
        :rtype: TreeNode
        :return: the parent of the node
        """
        return self.parent

    def setparent(self, newparent):
        """
        :rtype: TreeNode
        :param newparent: the new parent of the node
        :return: the new parent of the node
        """
        self.parent = newparent
        return self.parent

    def getchildren(self):
        """
        :rtype: TreeNode
        :return: the children of the node
        """
        return self.children

    def setchildren(self, newchildren):
        """
        :rtype: TreeNode
        :param newchildren: new children of the node
        :return: new children of the node
        """
        self.children = newchildren
        return self.children

    def addchild(self, newchild):
        """
        :rtype: TreeNode
        :param newchild: the new child of the node
        :return: new children of the node
        """
        self.children.append(newchild)
        return self.children
